/**
 * @author 03010570
 * @date 2020/06/30
 * LeetCode : Offer 11 、旋转数组中的最小数字   https://leetcode-cn.com/problems/xuan-zhuan-shu-zu-de-zui-xiao-shu-zi-lcof/
 */
public class LeetCode_sword_offer_11 {

    public static void main(String[] args) {

        System.out.println(minArray(new int[]{1,3,5}));
        System.out.println(minArray(new int[]{3,4,5,1,2}));
        System.out.println(minArray(new int[]{2, 2, 2, 0, 1}));
    }

    public static int minArray(int[] numbers) {
        int start = 0 , end = numbers.length - 1;
        while( start <= end){
            int middle = start + ((end - start) >>1);
            if(numbers[middle] < numbers[end]){
                end =middle;
            }else if(numbers[middle] > numbers[end]){
                start = middle +1;
            }else {
                end --;
            }
        }
        return numbers[start];

    }

}
